/*
 * Node.h
 *
 *  Created on: 18/09/2011
 *      Author: godinho
 */

#ifndef NODE_H_
#define NODE_H_

#include <string>
#include <vector>

namespace localview {

class Phase;
class Link;

class Node {

public:

	/**
	 * Constructor
	 */
	Node(std::string id);

	/**
	 * Desctructor
	 */
	virtual ~Node();

	/**
	 * Returns node id.
	 *
	 * A string that identifies the node on network
	 */
	std::string getId();

	/**
	 * Add a new phase for this node.
	 *
	 * @see Phase
	 *
	 * @param phase Object that defines a traffic light phase.
	 */
	void addPhase(Phase* phase);

	/**
	 * Return number of phases on this traffic light controler.
	 *
	 * @return number of phases
	 */
	int getPhaseCount();

	/**
	 * Get the nth phase on this node.
	 *
	 * @param n Index of phase
	 * @return object that holds phase definition.
	 */
	Phase* getPhase(int n);

	std::vector<Link*> getLinks();

	std::vector<Phase*> getPhase();

	int getLinkCount();

	Link* getLink(int index);

	void addLink(Link* l);

	int getX();

	void setX(int x);

	int getY();

	void setY(int y);

	/**
	 * Traversal status indicates if a node was not yet enqueued, if it was enqueued or
	 * if it was visited.
	 *
	 * @param s this can be
	 * 			0 - not enqueued (WHTE)
	 * 			1 - enqueued (GRAY)
	 * 			2 - visited (BLACK)
	 *
	 * 	@see TRAVERSAL_STATUS
	 */
	void setTraversalStatus(int s);

	int getTraversalStatus();

	std::vector<Phase*> getPhases();

	enum TRAVERSAL_STATUS{
		WHITE = 0,
		GRAY = 1,
		BLACK = 2
	};

/*
 * Local view
 */
private:

	std::string mId;

	std::vector<Link*> mLinks;

	std::vector<Phase*> mPhases;

	int mX;

	int mY;

	int mTraversalStatus;
};

}

#endif /* NODE_H_ */
